﻿using System.Text;

namespace Navigant.Infrastructure.Cases
{
    public class CaseSetting
    {
        #region Properties

        public string Name { get; set; }
        public int NumberValue { get; set; }
        public string StringValue { get; set; }

        #endregion

        #region Equality Tests

        public override bool Equals(object obj)
        {
            return obj != null
                && obj.GetType() == typeof(CaseSetting)
                && this == (CaseSetting)obj;
        }

        public override int GetHashCode()
        {
            return this.Name.GetHashCode()
                ^ this.NumberValue.GetHashCode()
                ^ this.StringValue.GetHashCode();
        }

        public static bool operator ==(CaseSetting one, CaseSetting other)
        {
            // check for both null (cast to object to avoid recursive loop)
            if ((object)one == null && (object)other == null)
            {
                return true;
            }

            // check for either of them equal to null
            if ((object)one == null || (object)other == null)
            {
                return false;
            }

            if (one.Name != other.Name
                || one.NumberValue != other.NumberValue
                || one.StringValue != other.StringValue)
            {
                return false;
            }

            return true;
        }

        public static bool operator !=(CaseSetting one, CaseSetting other)
        {
            return !(one == other);
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(200);
            builder.Append(this.Name);
            builder.Append("\r\n");
            builder.Append(this.NumberValue);
            builder.Append(", ");
            builder.Append(this.StringValue);
            return builder.ToString();
        }

        #endregion
    }
}
